# -*- coding: utf-8 -*-
# !/usr/bin/python3

import datetime
from models.Base import Base
from sqlalchemy import Column, String, Integer, DateTime, Text


class HandlePdfPartitionModel(Base):
    # 状态
    status_unprocessed = 0      # 待处理
    status_processed = 1        # 已处理

    now = datetime.datetime.now()

    """
    Pre Model
    """
    __tablename__ = 'handle_pdf_partition'
    id = Column(Integer(), primary_key=True, autoincrement=True)
    hp_id = Column(Integer(), default=0)
    file_path = Column(String(255), default='')
    content = Column(Text(), default='')
    personal_name = Column(String(128), default='')
    status = Column(Integer(), default=0)
    create_at = Column(DateTime(), default=now.strftime("%Y-%m-%d %H:%M:%S"))
    update_at = Column(DateTime(), default=now.strftime("%Y-%m-%d %H:%M:%S"))

    @property
    def serialize(self):
        return {
            'id': self.id,
            'hp_id': self.hp_id,
            'file_path': self.file_path,
            'content': self.content,
            'personal_name': self.personal_name,
            'status': self.status,
            'create_at': self.create_at,
            'update_at': self.update_at
        }
